Skip to content

Conversation

RussellRollins
Copy link

Resolves #76

This PR attempts a relatively simple fix, by checking if the plugin is already on the PATH when executing the command, and choosing the pre-existing copy if so.

Users who are concerned about re-downloading the binary can then modify their Buildkite Agent Workers to have a pre-cached binary that they have checksum'd and validated as they please.

@RussellRollins RussellRollins requested a review from a team as a code owner June 17, 2025 13:07
Copy link
Contributor

@toote toote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe a better way to implement the same thing would be to:

  • change the test_mode variable to something more like download_if_not_exists
  • just check that the command exists (with check_cmd) and fail if it doesn't

That way there is no need for additional variables or logic, defaults will be more secure or stable and there is a more explicit indication that something will be downloaded off the internet... even if that means a major release due to backwards-incompatible changes.

Finally, it would require the appropriate tests and documentation

@@ -96,18 +96,25 @@ download_binary_and_run() {
fi

local test_mode="${BUILDKITE_PLUGIN_MONOREPO_DIFF_BUILDKITE_PLUGIN_TEST_MODE:-false}"
local _command="./${_executable}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using this default value hides the fact that the variable is then used incorrectly unless the value is modified to remove the starting ./

Comment on lines +104 to +106
if check_cmd monorepo-diff-buildkite-plugin; then
_command="$(command -v monorepo-diff-buildkite-plugin)"
else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a way to still force a download

@RussellRollins
Copy link
Author

RussellRollins commented Jun 19, 2025

@toote

I believe a better way to implement the same thing would be to:

  • change the test_mode variable to something more like download_if_not_exists
  • just check that the command exists (with check_cmd) and fail if it doesn't

That way there is no need for additional variables or logic, defaults will be more secure or stable and there is a more explicit indication that something will be downloaded off the internet... even if that means a major release due to backwards-incompatible changes.

I want to make sure I understand properly. You're asking me add a new YAML parameter to the plugin, something like download_if_not_exists and make that default to false?

Then I will modify the script so that the script only does the download of the binary when that parameter is true, otherwise it will use check_cmd and fail if not already installed.

Finally, it would require the appropriate tests and documentation

It appears that the tests over this functionality were intentionally removed in this PR. As far as I can tell, the current tests only test that the plugin configuration is loaded properly, not actually executing the bash script (although maybe I'm misunderstanding). You're just asking me to include tests to cover the new download_if_not_exists parameter after I add it?

@toote
Copy link
Contributor

toote commented Jun 20, 2025

I want to make sure I understand properly. You're asking me add a new YAML parameter to the plugin, something like download_if_not_exists and make that default to false?

Correct. Most of the logic for that is already behind the test-mode of the plugin used to test it in the pipeline so it wouldn't make it more complicated or convoluted... I even believe it may make it more simple instead.

You're just asking me to include tests to cover the new download_if_not_exists parameter after I add it?

That is correct, but tests were secondary to the documentation of the option and the plugin behaviour.

@valkum
Copy link

valkum commented Jun 26, 2025

It should also make sure that the correct version is installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a way to pre-install the monorepo-diff binary
3 participants